package jp.ac.aiit.spg.entity;

import java.io.Serializable;
import java.util.*;
import javax.persistence.*;

import jp.ac.aiit.spg.common.SpgRole;

@Entity
public class SpgMember implements Serializable {


	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	// version ***********************************
	@Version
	private Integer version;

	public Integer getVersion() {
		return version;
	}

	public void setVersion(Integer version) {
		this.version = version;
	}

	// id ***********************************
	@Id
	@GeneratedValue
	private Integer id;

	public Integer getId() {
		return this.id;
	}
	
	// プロジェクト（１つ）***********************
	@ManyToOne
	private SpgProject project;

	public SpgProject getProject() {
		return project;
	}

	public void setProject(SpgProject project) {
		this.project = project;
	}

	// ユーザー（１つ）***********************
	@ManyToOne
	private SpgUser user;

	public SpgUser getUser() {
		return user;
	}

	public void setUser(SpgUser user) {
		this.user = user;
	}
	
	// 役割 *********************************
	@Enumerated
	private SpgRole role;
	
	
	public SpgRole getRole() {
		return role;
	}

	public void setRole(SpgRole role) {
		this.role = role;
	}


	
	// 割り当てられたタスク（複数） ***********************
	@OneToMany(mappedBy="member")
	private Collection<SpgTask> tasks = new HashSet<SpgTask>();
	
	public Collection<SpgTask> getTasks(){
		return this.tasks;
	}

	public void setTasks(Collection<SpgTask> tasks) {
		this.tasks = tasks;
	}
	
	public void addTask(SpgTask st) {
		this.tasks.add(st);
	}
	
	public void removeTask(SpgTask st) {
		this.tasks.remove(st);
	}


	
	
}
